#ifndef DATA_H
#define DATA_H
#include <boost/shared_ptr.hpp>
#include <cstring>
//ppm picture format file head information
#define PPMHEAD (sizeof("P6\n320 240\n255\n"))

namespace  DataUtil
{
    enum Direct
    {
        go, left, right, back, stop
    };
}

class Data
{
public:
    typedef boost::shared_ptr<Data> DataPtr;

    Data();
    int   GetRecvDataHeadSize();
    char* GetRecvDataHeadPtr();
    int   GetPictureDataSize();
    char* GetPictureDataPtr();
    int   GetSendDataSize();
    char* GetSendDataPtr();
    int   GetPPMsize();
    unsigned char* GetPPMptr();

    int getWidth() const;
    void setWidth(int value);

    int getHeight() const;
    void setHeight(int value);

    int getValidDataSize() const;
    void setValidDataSize(int size);

    void setDirect(DataUtil::Direct dir);

    void ReadYUV420(u_int8_t* data[4], int linesize[4]);



private:
    int exchangeDataHeadSize;
    int width;
    int height;

    struct {
        char head[PPMHEAD];
        char data[640*480*3];
    }ppmData;
    int  validSize;//valid data size in data array



    enum {
        MJPEG,
        YUYV,
        RGB
    }type;

    char sendData[4];
};

#endif // DATA_H
